// run: $exec < input
#include <iostream>
#include <vector>

int const maxn = 100010;
int const  inf = 1 << 30;

std::vector<int> graph[maxn];
int value[maxn], vmax[maxn], vmin[maxn], depth[maxn];
int leaf[maxn];
int n, k, l;

void dfs(int x, int dep, int one)
{
	vmax[x] = -inf; vmin[x] = inf;
	depth[x] = dep - one;
	for (int i = 0; i < (int)graph[x].size(); i++) {
		int v = graph[x][i];
		int tmp_one = 0;
		if (graph[x].size() == 1) tmp_one = 1;
		dfs(v, dep + 1, tmp_one + one);
		leaf[x] += leaf[v];
		vmax[x] = std::max(vmax[x], vmax[v]);
		vmin[x] = std::min(vmin[x], vmin[v]);
	}
	if (!graph[x].size()) {
		l++;
		leaf[x] = 1;
		vmax[x] = vmin[x] = value[x];
	}
}

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> k;
	for (int i = 1, p; i < n; i++) {
		std::cin >> p;
		graph[--p].push_back(i);
	}
	for (int i = 0; i < n; i++) std::cin >> value[i];

	dfs(0, 0, 0);
#ifdef __DEBUG
	std::cout << "vmin = \n";
	for (int i = 0; i < n; i++) std::cout << vmin[i] << ' ';
	std::cout << '\n';

	std::cout << "vmax = \n";
	for (int i = 0; i < n; i++) std::cout << vmax[i] << ' ';
	std::cout << '\n';

	std::cout << "depth = \n";
	for (int i = 0; i < n; i++) std::cout << depth[i] << ' ';
	std::cout << '\n';
#endif

	int ans_min = inf, ans_max = -inf;
	for (int i = 0; i < n; i++) {
		if (depth[i] <= k) ans_min = std::min(ans_min, vmax[i]);
		if (depth[i] <= n - l - k) ans_max = std::max(ans_max, vmin[i]);
	}
	std::cout << ans_min << ' ' << ans_max << '\n';
}

